import axios from "axios";
const baseURL = process.env.NODE_ENV === "development" ? "" : "";

const instance = axios.create({
    baseURL: baseURL + "/",
    timeout: 5000, //最长请求时间
    headers: {
        "Content-Type": "application/json;charset=UTF-8",
    },
});

instance.interceptors.request.use(
    (config) => {
        return config;
    },
    (error) => {
        return Promise.reject(error);
    }
);

instance.interceptors.response.use(
    (response) => {
        const { data } = response;
        const { code, msg } = data;

        if (code !== "200") {
            return data;
        } else {
            return data;
        }
    },
    (error) => {
        return Promise.reject(error);
    }
);

export default instance;

